package com.scnu.edu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.scnu.edu.entity.Director;
import com.scnu.edu.entity.Movie;
import com.scnu.edu.mapper.DirectorMapper;
import com.scnu.edu.mapper.MovieMapper;
import com.scnu.edu.service.DirectorService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DirectorServiceImpl extends ServiceImpl<DirectorMapper, Director> implements DirectorService {
    
    @Resource
    private MovieMapper movieMapper;
    


    @Override
    public List<Director> findDirectorsByMovieId(Long movieId) {
        // 假设电影和导演是多对多关系，通过关联表movie_director查询
        LambdaQueryWrapper<Director> wrapper = new LambdaQueryWrapper<>();
        wrapper.inSql(Director::getId, "SELECT director_id FROM movie_director WHERE movie_id = " + movieId);
        return this.list(wrapper);
    }
}